(function() {

	var appModule = angular.module('tracecashModule');

	appModule.filter('formatPerson', function() {
		return function(person) {
			var result = ' ';
			if (person != null) {
				result += (person.idCardNumber == null) ? '' : (person.idCardNumber + ' - ');
				result += ' ';
				result += (person.name == null) ? '' : person.name;
				result += ' ';
				result += (person.surname1 == null) ? '' : person.surname1;
			}
			return result;
		};
	});

	appModule.filter('zpad', function() {
		return function(input, n) {
			if (input === undefined) {
				input = "";
			}
			if (input.length >= n) {
				return input;
			}
			var result = input;
			while (result.length < n) {
				result = "0" + result;
			}
			return result;
		};
	});

	appModule.filter('range', function() {
		return function(input, min, max, reverse) {
			min = parseInt(min);
			max = parseInt(max);
			if (reverse) {
				for (var i = max; i >= min; i--) {
					input.push(i);
				}
			} else {
				for (var i = min; i <= max; i++) {
					input.push(i);
				}
			}
			return input;
		};
	});

	appModule.filter('amount', function() {
		return function(input) {
			if (input === undefined) {
				input = "";
			}
			return input + ' €';
		};
	});

})();